package com.ruoyi.project.system.parawork.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.parawork.domain.PaeaTaskLimitPara;
import com.ruoyi.project.system.parawork.service.IPaeaTaskLimitParaService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 流程处理期限参数Controller
 *
 * @author ruoyi
 * @date 2020-03-12
 */
@Controller
@RequestMapping("/system/parawork")
public class PaeaTaskLimitParaController extends BaseController
{
    private String prefix = "system/parawork";

    @Autowired
    private IPaeaTaskLimitParaService paeaTaskLimitParaService;

    @RequiresPermissions("system:parawork:view")
    @GetMapping()
    public String parawork()
    {
        return prefix + "/parawork";
    }

    /**
     * 查询流程处理期限参数列表
     */
    @RequiresPermissions("system:parawork:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaTaskLimitPara paeaTaskLimitPara)
    {
        startPage();
        List<PaeaTaskLimitPara> list = paeaTaskLimitParaService.selectPaeaTaskLimitParaList(paeaTaskLimitPara);
        return getDataTable(list);
    }

    /**
     * 导出流程处理期限参数列表
     */
    @RequiresPermissions("system:parawork:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaTaskLimitPara paeaTaskLimitPara)
    {
        List<PaeaTaskLimitPara> list = paeaTaskLimitParaService.selectPaeaTaskLimitParaList(paeaTaskLimitPara);
        ExcelUtil<PaeaTaskLimitPara> util = new ExcelUtil<PaeaTaskLimitPara>(PaeaTaskLimitPara.class);
        return util.exportExcel(list, "parawork");
    }

    /**
     * 新增流程处理期限参数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流程处理期限参数
     */
    @RequiresPermissions("system:parawork:add")
    @Log(title = "流程处理期限参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaTaskLimitPara paeaTaskLimitPara)
    {
        return toAjax(paeaTaskLimitParaService.insertPaeaTaskLimitPara(paeaTaskLimitPara));
    }

    /**
     * 修改流程处理期限参数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaTaskLimitPara paeaTaskLimitPara = paeaTaskLimitParaService.selectPaeaTaskLimitParaById(id);
        mmap.put("paeaTaskLimitPara", paeaTaskLimitPara);
        return prefix + "/edit";
    }

    /**
     * 修改保存流程处理期限参数
     */
    @RequiresPermissions("system:parawork:edit")
    @Log(title = "流程处理期限参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaTaskLimitPara paeaTaskLimitPara)
    {
        return toAjax(paeaTaskLimitParaService.updatePaeaTaskLimitPara(paeaTaskLimitPara));
    }

    /**
     * 删除流程处理期限参数
     */
    @RequiresPermissions("system:parawork:remove")
    @Log(title = "流程处理期限参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaTaskLimitParaService.deletePaeaTaskLimitParaByIds(ids));
    }
}
